package com.xncoding.websocket.api.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
//@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "ResultBean", description = "json返回结果类")
public class Result<T> {
    @ApiModelProperty(value = "状态码", example = "2")
    private String code;
    @ApiModelProperty("返回消息")
    private String message;
    @ApiModelProperty("返回数据")
    private T body;

    public static <T> Result<T> suc(T body, String message) {
        return new Result(body, message);
    }

    public static <T> Result<T> success(T body) {
        return new Result(body);
    }

    public static <T> Result<T> success(String message) {
        return new Result(message);
    }

    public static <T> Result<T> fail(String code, String message) {
        return new Result(code, message);
    }

    private Result(T body, String message) {
        this.code = "000000";
        this.message = message;
        this.body = body;
    }

    private Result(T body) {
        this.code = "000000";
        this.message = "success";
        this.body = body;
    }

    private Result(String message) {
        this.code = "000000";
        this.message = message;
    }

    private Result(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public T getBody() {
        return this.body;
    }
}
